package jdbc;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author 李明洋
 * @date 2025/3/26 14:03
 * @version: 1.0
 */
public class JDBCDemo11 {
    public static void main(String[] args) {
        try(Connection connection = DBUti1.getconnection();) {
            connection.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
            connection.setAutoCommit(false);
            String sql = "insert into user(username,password,nickname,age) values(?,?,?,?)";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"老三");
            ps.setString(2,"123456");
            ps.setString(3,"三儿");
            ps.setInt(4,22);
            int num = ps.executeUpdate();
            System.out.println(num>0?"插入成功":"插入失败");
            connection.commit();

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
